#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<queue>

using namespace std;
long long n,l,r;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%lld%lld%lld",&n,&l,&r);
	long long tmp=l%n,maxnum=r-l;
	if(maxnum+tmp>=n-1)printf("%lld",n-1);
	else printf("%lld",maxnum+tmp);
	return 0;
}

